/*-------------------------------------------------------------------------
 *
 * tblspcdesc.c
 *	  rmgr 描述例程，用于 commands/tablespace.c
 *
 * Portions Copyright (c) 1996-2022, PostgreSQL Global Development Group
 * Portions Copyright (c) 1994, Regents of the University of California
 *
 *
 * IDENTIFICATION
 *	  src/backend/access/rmgrdesc/tblspcdesc.c
 *
 *-------------------------------------------------------------------------
 */
#include "postgres.h"

#include "commands/tablespace.h"


void tblspc_desc(StringInfo fc_buf, XLogReaderState *fc_record)
{
	char	   *fc_rec = XLogRecGetData(fc_record);
	uint8		fc_info = XLogRecGetInfo(fc_record) & ~XLR_INFO_MASK;

	if (fc_info == XLOG_TBLSPC_CREATE)
	{
		xl_tblspc_create_rec *fc_xlrec = (xl_tblspc_create_rec *) fc_rec;

		appendStringInfo(fc_buf, "%u \"%s\"", fc_xlrec->ts_id, fc_xlrec->ts_path);
	}
	else if (fc_info == XLOG_TBLSPC_DROP)
	{
		xl_tblspc_drop_rec *fc_xlrec = (xl_tblspc_drop_rec *) fc_rec;

		appendStringInfo(fc_buf, "%u", fc_xlrec->ts_id);
	}
}

const char * tblspc_identify(uint8 fc_info)
{
	const char *fc_id = NULL;

	switch (fc_info & ~XLR_INFO_MASK)
	{
		case XLOG_TBLSPC_CREATE:
			fc_id = "CREATE";
			break;
		case XLOG_TBLSPC_DROP:
			fc_id = "DROP";
			break;
	}

	return fc_id;
}
